package com.example.bank.controller;

import com.example.bank.entity.Deposit;
import com.example.bank.service.IDepositService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2025-06-19
 */
@RestController
@RequestMapping("/deposit")
public class DepositController {
    @Autowired
    private IDepositService depositService;

    @GetMapping
    public List<Deposit> list() {
        return depositService.list();
    }

    @GetMapping("/{id}")
    public Deposit getById(@PathVariable Long id) {
        return depositService.getById(id);
    }

    @PostMapping
    public boolean save(@RequestBody Deposit deposit) {
        return depositService.save(deposit);
    }

    @PutMapping
    public boolean update(@RequestBody Deposit deposit) {
        return depositService.updateById(deposit);
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Long id) {
        return depositService.removeById(id);
    }
}
